<template>
	<view class="housemain"  @click="todetail(obj)">
		<view class="house-imgs">
			<img :src="obj.imgs" alt="" srcset="" class="img"> 
		</view> 
		<view class="house-text">
			<view class="name">{{obj.name}}</view>
			<text class="type">{{obj.type}}/{{obj.point}}m²/{{obj.range}}</text>
			<!-- <text class="news-range"></text> -->
			<view class="taps">
				<view class="">{{obj.taps}}</view>
			</view>  
			<view class="price">{{obj.price}}元/平</view> 
		</view> 
	</view>
</template>

<script>
	export default {
		name:"likes",
		props:{
			obj:{
				type:Object,
				default:{
					area: "",
					id: 0,
					imgs: "",
					name: "",
					point: 0,
					price: 0,
					range: "",
					tabs: "",
					type: "",
				},
				// area: "仁寿县"
				// id: 1
				// imgs: "http://129.211.169.131:6368/imgs/1.jpg"
				// name: "美的云溪郡"
				// point: 117
				// price: 9000
				// range: "仁寿大道"
				// tabs: "['近地铁','公园房']"
				// type: "4室2厅"
			} 
		},
		data() {
			return {
				
			};
		},
		created() {
			
		},
		methods:{
			todetail(item){ 
				// console.log(55,item);
				// this.$emit("detail",item.id)
				uni.navigateTo({
					url:"/pages/detail/detail?item="+JSON.stringify(item) 
				}) 
				// uni.setStorageSync("item",JSON.stringify(item))
				let arr=uni.getStorageSync("historyText");
				if(arr){
					arr.map((v,i)=>{
						// console.log(64,v);
						// console.log(65,v.id);
						if(v.id==item.id){
						  arr.splice(i,1)
						}
						
					})
					// for (let i=0;i<arr.length;i++) {
					// 	if(arr[i].id==item.id){
					// 		arr.splice(i,1)
					// 		break
					// 	}
					// }
					arr.unshift(item)
				}else{
					arr=[];
					arr.unshift(item)
				} 
				uni.setStorageSync("historyText",arr);
				// console.log(69,arr);
			},
		}
	}
</script>

<style lang="scss"> 
	.housemain{
		margin: 20px;
		display: flex;
		justify-content: space-between;
		flex: 1;
	} 
	.house-imgs{
		display: flex; 
		justify-content: space-evenly;
	}
	.house-text{
		margin-right: 50px;
		display: flex;
		flex-direction: column;
		justify-content: center;
	}
	.img{
		width: 250rpx;
		height: 200rpx;
	}
	.name{
		font-weight: bold;
	}
	.type{
		font-size: 12px;
	}
	.taps{
		font-size: 12px;
	}
	.price{
		color: #999;
		font-size: 12px;
	}
	
</style>